package hht.dragon.blog.mapper;

import hht.dragon.blog.common.api.ReturnData;
import hht.dragon.blog.common.api.utils.Returns;
import hht.dragon.blog.model.Type;
import hht.dragon.blog.service.TypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.util.List;

/**
 * 类型Controller.
 * User: huang
 * Date: 18-6-24
 */
@RestController
@RequestMapping("/type")
public class TypeController {

    @Autowired
    private TypeService typeService;

    /**
     * 获取所有类型.
     * @return 所有类型信息
     */
    @GetMapping("/get/all")
    public Mono<ReturnData<List<Type>>> getAllType() {
        List<Type> types = typeService.getAllTypes();
        return Returns.newMonoReturnData(200, types);
    }

}
